#include "flatsurface.h"
#include "functions.h"

// =================================================================================================
// Intersection test for a flat surface
// =================================================================================================
float FlatSurface::SurfaceIntersection(const Ray& ray) {
    // -- compute d of the plane
    float d1 = -(DotProduct(plane.normal, ray.origin));
    float d = d1 + (DotProduct(plane.normal, plane.origin));
    float denom = (DotProduct(plane.normal, ray.direction));
    float t = d/denom;

    // -- return the scalar value
    return t;
}
